package com.nuttysoft.nutand.views;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

/**
 * Created by Administrator on 2016/3/9 0009.
 */
public class TabItem extends LinearLayout {

    private Context context;
    private  ImageView itemImg;
    private TextView textView;

    public TabItem(Context context) {
        super(context);
        this.context = context;
        initView();
    }

    public TabItem(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        initView();
    }

    public TabItem(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
        initView();
    }

    private void initView(){
        this.setOrientation(LinearLayout.VERTICAL);

        itemImg = new ImageView(context);
        textView= new TextView(context);

        LayoutParams itemParams = new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
        itemParams.gravity = Gravity.CENTER_HORIZONTAL;

        this.addView(itemImg,itemParams);
        this.addView(textView,itemParams);
    }

    public void setText(String title){

        textView.setText(title);
    }

    public void setTextColor(int color){
        textView.setTextColor(color);
    }

    public void setimgRes(int resId){
        itemImg.setImageResource(resId);
    }
}
